﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Automation;
using System.Windows.Forms;

namespace UIAutomation
{
    class Program
    {
        static void Main(string[] args)
        {
            var root = AutomationElement.RootElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "Decabrina IV Deep, Ante - $100/$200 Ante $40 USD - No Limit Hold'em"));
            if (root != null)
            {
                Console.WriteLine("I have the window");
                var panes = root.FindAll(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Pane));
                if (panes != null)
                {
                    Console.WriteLine("I have " + panes.Count + " panes");
                    foreach (var pane in panes)
                    {
                        var box = pane as AutomationElement;
                        if (box != null)
                        {
                            Console.WriteLine("=============================================");
                            Console.WriteLine("ClassName : " + box.Current.ClassName);
                            Console.WriteLine("AutomationId : " + box.Current.AutomationId);
                            Console.WriteLine("FrameworkId : " + box.Current.FrameworkId);
                            Console.WriteLine("ItemType : " + box.Current.ItemType);
                            Console.WriteLine("ItemStatus : " + box.Current.ItemStatus);
                            //Console.WriteLine("Name : " + box.Current.Name);
                            Console.WriteLine("NativeWindowHandle : " + box.Current.NativeWindowHandle);
                            Console.WriteLine("ControlType : " + box.Current.ControlType);
                            //Console.WriteLine("LabeledBy : " + box.Current.LabeledBy);
                        }
                    }
                }
            }
            Console.ReadLine();
        }
    }
}

